home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / elm / elm2.4 / src / delete.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-03  |  4.7 KB  |  180 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: delete.c,v 5.1 1992/10/03 22:58:40 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
  6.  *
  7.  *             Copyright (c) 1988-1992 USENET Community Trust
  8.  *             Copyright (c) 1986,1987 Dave Taylor
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log: delete.c,v $
  17.  * Revision 5.1  1992/10/03  22:58:40  syd
  18.  * Initial checkin as of 2.4 Release at PL0
  19.  *
  20.  *
  21.  ******************************************************************************/
  22.  
  23. /**  Delete or undelete files: just set flag in header record! 
  24.      Also tags specified message(s)...
  25.  
  26. **/
  27.  
  28. #include "headers.h"
  29. #include "s_elm.h"
  30.  
  31. char *show_status();
  32.  
  33. delete_msg(real_del, update_screen)
  34. int real_del, update_screen;
  35. {
  36.     /** Delete current message.  If real-del is false, then we're
  37.         actually requested to toggle the state of the current
  38.         message... **/
  39.  
  40.     if (real_del) {
  41.       if (inalias) {
  42.         if (aliases[current-1]->type & SYSTEM)
  43.           error(catgets(elm_msg_cat, ElmSet, ElmNoDelSysAlias,
  44.         "Can't delete a system alias!"));
  45.         else
  46.           setit(aliases[current-1]->status, DELETED);
  47.       }
  48.       else
  49.         setit(headers[current-1]->status, DELETED);
  50.     }
  51.     else {
  52.       if (inalias) {
  53.         if (aliases[current-1]->type & SYSTEM)
  54.           error(catgets(elm_msg_cat, ElmSet, ElmNoDelSysAlias,
  55.         "Can't delete a system alias!"));
  56.         else if (ison(aliases[current-1]->status, DELETED))
  57.           clearit(aliases[current-1]->status, DELETED);
  58.         else
  59.           setit(aliases[current-1]->status, DELETED);
  60.       }
  61.       else if (ison(headers[current-1]->status, DELETED))
  62.         clearit(headers[current-1]->status, DELETED);
  63.       else
  64.         setit(headers[current-1]->status, DELETED);
  65.     }
  66.  
  67.     if (update_screen)
  68.       show_msg_status(current-1);
  69. }
  70.  
  71. undelete_msg(update_screen)
  72. int update_screen;
  73. {
  74.     /** clear the deleted message flag **/
  75.  
  76.     if (inalias)
  77.       clearit(aliases[current-1]->status, DELETED);
  78.     else
  79.       clearit(headers[current-1]->status, DELETED);
  80.  
  81.     if (update_screen)
  82.       show_msg_status(current-1);
  83. }
  84.  
  85. show_msg_status(msg)
  86. int msg;
  87. {
  88.     /** show the status of the current message only.  **/
  89.  
  90.     char tempbuf[3];
  91.  
  92.     strcpy(tempbuf, show_status(ifmain(headers[msg]->status,
  93.                                        aliases[msg]->status)));
  94.  
  95.     if (on_page(msg)) {
  96.       MoveCursor(((compute_visible(msg+1)-1) % headers_per_page) + 4, 2);
  97.       if (msg+1 == current && !arrow_cursor) {
  98.         StartBold();
  99.         Writechar( tempbuf[0] );
  100.         EndBold();
  101.       }
  102.       else
  103.         Writechar( tempbuf[0] );
  104.     }
  105. }
  106.  
  107. int
  108. tag_message(update_screen)
  109. int update_screen;
  110. {
  111.     /** Tag current message and return TRUE.
  112.         If already tagged, untag it and return FALSE. **/
  113.  
  114.     int istagged;
  115.  
  116.     if (ison(ifmain(headers[current-1]->status,
  117.                     aliases[current-1]->status), TAGGED)) {
  118.       if (inalias)
  119.         clearit(aliases[current-1]->status, TAGGED);
  120.       else
  121.         clearit(headers[current-1]->status, TAGGED);
  122.       istagged = FALSE;
  123.     } else {
  124.       if (inalias)
  125.         setit(aliases[current-1]->status, TAGGED);
  126.       else
  127.         setit(headers[current-1]->status, TAGGED);
  128.       istagged = TRUE;
  129.     }
  130.  
  131.     if(update_screen)
  132.         show_msg_tag(current-1);
  133.     return(istagged);
  134. }
  135.  
  136. show_msg_tag(msg)
  137. int msg;
  138. {
  139.     /** show the tag status of the current message only.  **/
  140.  
  141.     if (on_page(msg)) {
  142.       MoveCursor(((compute_visible(msg+1)-1) % headers_per_page) + 4, 4);
  143.       if (msg+1 == current && !arrow_cursor) {
  144.         StartBold();
  145.         Writechar( ison(ifmain(headers[msg]->status,
  146.                                aliases[msg]->status), TAGGED)? '+' : ' ');
  147.         EndBold();
  148.       }
  149.       else
  150.         Writechar( ison(ifmain(headers[msg]->status,
  151.                                aliases[msg]->status), TAGGED)? '+' : ' ');
  152.     }    
  153. }
  154.  
  155. show_new_status(msg)
  156. int msg;
  157. {
  158.     /** If the specified message is on this screen, show
  159.         the new status (could be marked for deletion now,
  160.         and could have tag removed...)
  161.     **/
  162.  
  163.     if (on_page(msg)) 
  164.       if (msg+1 == current && !arrow_cursor) {
  165.         StartBold();
  166.         PutLine2(((compute_visible(msg+1)-1) % headers_per_page) + 4,
  167.            2, "%s%c", show_status(ifmain(headers[msg]->status,
  168.                                          aliases[msg]->status)),
  169.            ison(ifmain(headers[msg]->status,
  170.                        aliases[msg]->status), TAGGED )? '+' : ' ');
  171.         EndBold();
  172.       }
  173.       else
  174.         PutLine2(((compute_visible(msg+1)-1) % headers_per_page) + 4,
  175.            2, "%s%c", show_status(ifmain(headers[msg]->status,
  176.                                          aliases[msg]->status)),
  177.            ison(ifmain(headers[msg]->status,
  178.                        aliases[msg]->status), TAGGED )? '+' : ' ');
  179. }
  180.